<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<!-- source http://www.scnoob.com More templates http://www.scnoob.com/moban -->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>用户列表</title>

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/bootstrap.min.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/fonts/line-icons.css}">

    <link th:href="@{/assets/plugins/datatables/dataTables.bootstrap4.min.css}" rel="stylesheet" type="text/css" />
    <link th:href="@{/assets/plugins/datatables/buttons.bootstrap4.min.css}" rel="stylesheet" type="text/css" />

    <link th:href="@{/assets/plugins/datatables/responsive.bootstrap4.min.css}" rel="stylesheet" type="text/css" />

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/main.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/responsive.css}">

</head>
<body>
<div class="app header-default side-nav-dark">
    <div class="layout">
        <div class="page-container pl-0">
            <div class="main-content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header border-bottom">
                                    <h4 class="card-title">用户列表</h4>
                                        <a href="/admin/user/add"  class="float-right">
                                            <button type="button" class="btn btn-outline-dark">添加新用户</button>
                                        </a>
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table id="datatable" class="table table-bordered" style="width: 100%">
                                            <thead>
                                            <tr>
                                                <th class="text-center">手机号码</th>
                                                <th>用户名</th>
                                                <th>真实姓名</th>
                                                <th class="text-center">邮箱地址</th>
                                                <th class="text-center">最后登录时间</th>
                                                <th class="text-center">操作</th>
                                            </tr>
                                            </thead>
                                            <!--<tbody>
                                            <tr th:each="user:${usersList}">
                                                <td th:text="${user.phone}"></td>
                                                <th scope="row" th:text="${user.username}"></th>
                                                <td th:text="${user.realName}"></td>
                                                <td th:text="${user.email}"></td>
                                                <td th:text="${user.lastLogin}"></td>
                                                <td class="text-center">
                                                    <a th:href="@{/admin/user/update(id=${user.id})}"><button type="button" class="btn btn-outline-info">修改</button></a>
                                                    <a th:href="@{/admin/user/resetPw(id=${user.id})}"><button type="button" class="btn btn-outline-warning">重置密码</button></a>
                                                </td>
                                            </tr>
                                            </tbody>-->
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>



            </div>

        </div>
    </div>
</div>

    <div id="preloader">
        <div class="loader" id="loader-1"></div>
    </div>

    <button value="添加"><a href="/admin/user/add"></a></button>


    <script th:src="@{/assets/js/jquery-min.js}"></script>
    <script th:src="@{/assets/js/popper.min.js}"></script>
    <script th:src="@{/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/js/jquery.app.js}"></script>
    <script th:src="@{/assets/js/main.js}"></script>

    <script th:src="@{/assets/plugins/datatables/jquery.dataTables.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/dataTables.bootstrap4.min.js}"></script>

    <script th:src="@{/assets/plugins/datatables/dataTables.buttons.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/buttons.bootstrap4.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/jszip.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/pdfmake.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/vfs_fonts.js}"></script>
    <script th:src="@{/assets/plugins/datatables/buttons.html5.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/buttons.print.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/buttons.colVis.min.js}"></script>

    <script th:src="@{/assets/plugins/datatables/dataTables.responsive.min.js}"></script>
    <script th:src="@{/assets/plugins/datatables/responsive.bootstrap4.min.js}"></script>

    <script th:src="@{/assets/js/datatables.init.js}"></script>

<script type="text/javascript" >
    $("#datatable").DataTable({
        "oLanguage": {
            "sUrl": "/assets/page_zh_CN.json"
        },
        serverSide: true, //开启后端模式
        bSort:false,
        // searching: false,  //禁用原生搜索
        // "pageLength": 10,         //初始化显示几条数据
        "sAjaxSource": "/admin/user/usersList?type=allUser",
        "fnServerData": function (sSource, aoData, fnCallback) {
            $.ajax({
                "dataType": 'json',
                "type": "POST",
                "url": sSource,
                "data": {
                    aoData: JSON.stringify(aoData)
                },
                "success": fnCallback
            });
        },
        "bDeferRender": true,// 是否启用延迟加载：当你使用AJAX数据源时，可以提升速度。默认值：False
        //列表表头字段
        "aoColumns": [
            {"mData": "phone","width":"17%","orderable" : false},
            {"mData": "username","width":"16%","orderable" : false},
            {"mData": "realname","width":"16%","orderable" : false},
            {"mData": "email","width":"17%","orderable" : false},
            {"mData": "lastlogin","width":"17%","orderable" : false},
            {"mData": "operation","width":"17%","orderable" : false}
        ],
        "aoColumnDefs": [
            {
                "sClass": "text-center",
                "aTargets": [5],
                "mData": "operation",
                "mRender": function (a, b, c, d) {//a表示productOperate对应的值，c表示当前记录行对象；product对象，b display ； d 当前行 当前列
                    console.log(c);
                    var html = '<a href="/admin/user/update?id='+c.operation+'">' +
                        '<button type="button" class="btn btn-outline-info">修改</button>' +
                        '</a>\n' +
                        '<a>' +
                        '<button type="button" class="btn btn-outline-warning" data-toggle="modal" data-target="#myModal'+c.operation+'">重置密码</button>' +
                        '</a>'+
                    '                               <!-- 模态框（Modal） -->\n' +
                        '                                                                      <div style="margin-top: 260px" class="modal fade" id="myModal'+c.operation+'" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">\n' +
                        '                                                                        <div class="modal-dialog">\n' +
                        '                                                                          <div class="modal-content">\n' +
                        '                                                                            <div class="modal-header">\n' +
                        '                                                                              <h4 class="modal-title" id="myModalLabel1">重置密码</h4>\n' +
                        '                                                                              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\n' +
                        '                                                                            </div>\n' +
                        '                                                                            <div class="modal-body">确认重置该用户的密码</div>\n' +
                        '                                                                            <div class="modal-footer">\n' +
                        '                                                                              <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>\n' +
                        '                                                                              <a href="/admin/user/resetPw?id='+c.operation+'"><button type="button" class="btn btn-primary">确认</button></a>\n' +
                        '                                                                            </div>\n' +
                        '                                                                          </div><!-- /.modal-content -->\n' +
                        '                                                                        </div><!-- /.modal -->\n' +
                        '                                                                      </div>';
                    return html;
                }
            }
        ]
    });
</script>
</body>

<!-- source http://www.scnoob.com More templates http://www.scnoob.com/moban -->
</html>